﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace sprocket
{
	public partial class TableListDlg : Form
	{
		private string _stateTableListCommand = null;

		public TableListDlg()
		{
			InitializeComponent();

			if( !this.HaveTableListCommandOverride )
			{
				this.TableListCommand = Properties.Resources.tableList;
			}
		}

		public new DialogResult ShowDialog(IWin32Window owner)
		{
			DialogResult result = DialogResult.None;

			_stateTableListCommand = this.TableListCommand;

			result = base.ShowDialog( owner );

			if( result == DialogResult.Cancel )
			{
				this.TableListCommand = _stateTableListCommand;
			}

			_stateTableListCommand = null;

			return result;
		}

		public string TableListCommand
		{
			get { return txtTableListCommand.Text; }
			set { txtTableListCommand.Text = value; }
		}

		public bool HaveTableListCommandOverride
		{
			get
			{
				return !string.IsNullOrEmpty( txtTableListCommand.Text ) &&
					txtTableListCommand.Text != Properties.Resources.tableList;
			}
		}
	}
}